package com.thymeleaf;

import service.ActorService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delete.do")
public class ActorDelete extends HttpServlet {
    private ActorService actorService = new ActorService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String idStr = req.getParameter("id");
        int id = Integer.parseInt(idStr);
        boolean delete = actorService.delete(id);
        if (delete) {
            resp.sendRedirect("list");
        } else {
            System.out.println("删除失败");
        }

    }
}
